int nQueen3(int queenTotal){
    int result = 0;
    if(queenTotal < 1){
        return result;
    }
    int *queensRow = new int[queenTotal],
      *queensColumn = new int[queenTotal],
      checkerRow = 0, checkerColumn = 0,
      queenPlaced = 0, queenRow, queenColumn,
      columnLast = queenTotal / 2, columnMax = (queenTotal + 1) / 2;
    bool isPlaceable;
    while(queenPlaced > 0 || (checkerColumn < columnMax && checkerRow == 0)){
        if(queenPlaced == checkerRow){
            isPlaceable = true;
            for(int i = 0; i < queenPlaced; ++i){
                queenRow = queensRow[i];
                queenColumn = queensColumn[i];
                if((queenRow == checkerRow) ||
                  (queenColumn == checkerColumn) ||
                  (queenColumn + queenRow == checkerColumn + checkerRow) ||
                  (checkerRow - queenRow == checkerColumn - queenColumn)
                ){
                    isPlaceable = false;
                    break;
                }
            }
            if(isPlaceable){
                queensRow[queenPlaced] = checkerRow;
                queensColumn[queenPlaced++] = checkerColumn;
                if(queenPlaced == queenTotal){
                    ++result;
                    if(queensColumn[0] != columnLast){
                        ++result;
                    }
                    checkerRow = queensRow[--queenPlaced];
                    checkerColumn = queensColumn[queenPlaced];
                    ++checkerColumn;
                    if(checkerColumn == queenTotal){
                        checkerColumn = 0;
                        ++checkerRow;
                    }
                }else{
                    checkerColumn = 0;
                    ++checkerRow;
                }
            }else{
                ++checkerColumn;
                if(checkerColumn == queenTotal){
                    checkerColumn = 0;
                    ++checkerRow;
                }
            }
        }else{
            checkerRow = queensRow[--queenPlaced];
            checkerColumn = queensColumn[queenPlaced];
            ++checkerColumn;
            if(checkerColumn == queenTotal){
                checkerColumn = 0;
                ++checkerRow;
            }
        }
    }
    delete []queensRow;
    delete []queensColumn;
    return result;
}
